<?php
namespace Home\Controller;
/**
 * 域名兑出
 * @author Administrator
 *
 */
class TurnoutlogController extends HomeBaseController
{
    public function index(){
        $sql="SELECT a.id,a.admin_remark,a.createdate,a.status,a.domain,a.pushid,c.name FROM dd_domain_turnoutlog a LEFT JOIN dd_register_business c ON a.regi_buines_id=c.id where a.uid=".session('uid')." order by a.id desc";
        $list = M('DomainTurnoutlog')->query($sql);
        $this->assign('list', $list);
        $count=M('DomainTurnoutlog')->where('uid='.session('uid'))->count();
        $this->assign('count', $count);
        $this->display('turnoutlog/index');
    }
    /**
     * 取消转出
     */
    public function cancel(){
        $id=I('id','');
        if(empty($id)){
            $this->ajaxReturn(array('status'=>'2','msg' => '不存在此域名转出记录!'));
            exit();
        }
        $turnlog =M('DomainTurnoutlog')->find($id);
        if(empty($turnlog)){
            $this->ajaxReturn(array('status'=>'2','msg' => '不存在此域名转出记录!'));
            exit();
        }
        if($turnlog['status']==1){
            M('UserDomains')->where('id='.$turnlog['udomainid'])->setField(array('trans_status'=>1));
            M('DomainTurnoutlog')->where('id='.$id)->delete();
        }
        $this->ajaxReturn(array('status'=>'1','msg' => '您域名转出已经取消!'));
    }
}